home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 870 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  66 lines

  1. Path: hp62.rbg.informatik.th-darmstadt.de!meixner
  2. From: meixner@rbg.informatik.th-darmstadt.de (Matthias Meixner)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: PPC compilers
  5. Date: 12 Jan 1996 12:31:10 GMT
  6. Organization: Technische Hochschule Darmstadt
  7. Message-ID: <4d5kae$24rg@rs18.hrz.th-darmstadt.de>
  8. References: <john.hendrikx.40ka@grafix.xs4all.nl> <MQAQx*XOe@yaps.rhein.de> <OWhVx*42f@yaps.rhein.de> <4cuhng$dmn@maureen.teleport.com> <jasonb.821247870@cs.uwa.edu.au> <4d359i$ii7$1@sydney.DIALix.oz.au>
  9. NNTP-Posting-Host: hp62.rbg.informatik.th-darmstadt.de
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Troy Till (accolyte@sydney.DIALix.oz.au) wrote:
  13. : Bear with me here, 'cause I don't know the second thing about C..
  14.  
  15. : can you do something to the equivalent of:
  16.  
  17. :   addx.l d0,d1
  18. :   move.w d1,d2
  19.  
  20. : Which is treating d1 as a long word, then a word. How would you implement 
  21. : this in C?
  22.  
  23.  
  24. struct words {
  25.     short high,low;
  26. };
  27.  
  28. union mixed {
  29.     long a_l;
  30.     struct words a_w;
  31. };
  32.  
  33.  
  34. function() {
  35.    union mixed variable;
  36.    short x;
  37.  
  38.    variable.a_l+=10; /* now this is a long */
  39.  
  40.    x=variable.a_w.low; /* now the same amount of memory is treated as a short */
  41. }
  42.  
  43. However in the above case, you would just assign a longword to the word and
  44. the compiler would do the conversion (i.e. in the case it would do e.g. move.w d1,d2)
  45.  
  46. long a;
  47. short b;
  48.  
  49. b=a;
  50.  
  51.  
  52. : Troy.
  53.  
  54. --
  55.  
  56. - Matthias Meixner
  57.  
  58. -----------------------------------------------------------------------------
  59. EMail: meixner@rbg.informatik.th-darmstadt.de  
  60. WWW:   http://www.student.informatik.th-darmstadt.de/~meixner/
  61.  
  62.          Uebrigens: Nachts gehen Sonnenuhren nach dem Mond ...
  63.  
  64.  
  65.  
  66.